"use strict";
cc._RF.push(module, '80574D7qBRAsou9/p8s0Ugx', 'LoadScene');
// Script/LoadScene.ts

"use strict";
/**
 * 加载场景
 */
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var Define_1 = require("./SdkTools/Define");
var gameCheckLogin_1 = require("./SdkTools/gameCheckLogin");
var gameNetWorkState_1 = require("./SdkTools/gameNetWorkState");
var gamePrefabMgr_1 = require("./SdkTools/gamePrefabMgr");
var gameShareAdsVideo_1 = require("./SdkTools/gameShareAdsVideo");
var storage_1 = require("./SdkTools/storage");
var TipsManager_1 = require("./SdkTools/TipsManager");
var TopUi_1 = require("./TopUi");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var LoadScene = /** @class */ (function (_super) {
    __extends(LoadScene, _super);
    function LoadScene() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.loadbar = null;
        // LIFE-CYCLE CALLBACKS:
        _this.loadOver = false;
        return _this;
    }
    LoadScene.prototype.onLoad = function () {
        this.loadOver = false;
        var self = this;
        if (cc.sys.platform == cc.sys.WECHAT_GAME) {
            //@ts-ignore
            var updateManager_1 = wx.getUpdateManager();
            updateManager_1.onCheckForUpdate(function (res) {
                // 请求完新版本信息的回调
                console.log(res.hasUpdate);
            });
            updateManager_1.onUpdateReady(function () {
                //@ts-ignore
                wx.showModal({
                    title: '更新提示',
                    content: '新版本已经准备好，是否重启应用？',
                    success: function (res) {
                        if (res.confirm) {
                            // 新的版本已经下载好，调用 applyUpdate 应用新版本并重启
                            updateManager_1.applyUpdate();
                        }
                    }
                });
            });
            //@ts-ignore
            wx.showShareMenu({
                success: function (res) {
                    console.log('开启被动转发成功!');
                },
                fail: function (res) {
                    console.log(res);
                    console.log('开启被动转发失败!');
                }
            });
            // 获取当前棋局oneChess信息，JSON.stringfy()后传入query
            //@ts-ignore
            wx.onShareAppMessage(function () {
                // return {
                //     title: '', 
                //     imageUrl: '',        // 分享图片要放在 wechatgame/res/raw-assets 路径下
                //     query: ''  // query最大长度(length)为2048
                // }
                return {
                    title: '80%老同学都卡在这里了，难道这关就这么难了吗？',
                    imageUrl: 'https://mmocgame.qpic.cn/wechatgame/fIiaXSY0ANicTRfDr395BbEDT0R54yO9lsUWiasL5Xg8XIcrwUOvqOA0vt6hMOp29tu/0',
                    query: '' // query最大长度(length)为2048
                };
            });
        }
        TipsManager_1.default.Instance.Initial(); //初始化
        gamePrefabMgr_1.default.Instance.Initial();
        gameShareAdsVideo_1.default.Instance.chaPingAds_Load();
        gameShareAdsVideo_1.default.Instance.motivational_Video_Load();
        gameShareAdsVideo_1.default.Instance.createCustomAd(Define_1.CustomAdType.Shu);
        gameShareAdsVideo_1.default.Instance.createCustomAd(Define_1.CustomAdType.More);
        gameCheckLogin_1.default.gameLogin(false);
        storage_1.default.Instance.eneryTime = Define_1.default.eneryTime;
        cc.game.on('addgold', function () {
            var topuisc = null;
            var sc = cc.find('Canvas/top').getComponent(TopUi_1.default);
            if (sc) {
                topuisc = sc;
            }
            var over = cc.find('Canvas/GameOver/top');
            if (over) {
                var sc2 = over.getComponent(TopUi_1.default);
                if (sc2) {
                    topuisc = sc2;
                }
            }
            if (topuisc) {
                topuisc.setGold();
            }
        });
        cc.game.on('addengry', function () {
            var topuisc = null;
            var sc = cc.find('Canvas/top').getComponent(TopUi_1.default);
            if (sc) {
                topuisc = sc;
            }
            var over = cc.find('Canvas/GameOver/top');
            if (over) {
                var sc2 = over.getComponent(TopUi_1.default);
                if (sc2) {
                    topuisc = sc2;
                }
            }
            if (topuisc) {
                topuisc.setTiLi();
            }
        });
        gameNetWorkState_1.default.Instance.getGameOpenState(function () { });
    };
    LoadScene.prototype.start = function () {
    };
    LoadScene.prototype.update = function (dt) {
        if (this.loadOver) {
            return;
        }
        this.loadbar.progress = gamePrefabMgr_1.default.Instance.jilv / gamePrefabMgr_1.default.Instance.allResNum;
        if (this.loadbar.progress >= 1) {
            this.loadOver = !0;
            cc.director.loadScene('StartScene');
        }
    };
    __decorate([
        property(cc.ProgressBar)
    ], LoadScene.prototype, "loadbar", void 0);
    LoadScene = __decorate([
        ccclass
    ], LoadScene);
    return LoadScene;
}(cc.Component));
exports.default = LoadScene;

cc._RF.pop();